package com.example.administrator.appstpremvpdemo.binder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.appstpremvpdemo.R;
import com.example.administrator.appstpremvpdemo.model.entity.ValueBean;
import com.example.administrator.appstpremvpdemo.util.TextFormaterUtils;

/**
 * @Author Administrator
 * @Date 2017/12/26
 * @description
 * @function
 */
public class AppListBinder extends BaseViewBinder {

    private TextView mTittle;
    private TextView mType;
    private TextView mSize;
    private TextView mScore;
    private TextView mDownloadCount;
    private ImageView mIcon;

    public AppListBinder(ViewGroup group, int layoutId) {
        super(group, layoutId);
    }

    @Override
    public void onViewInflate(View rootView) {
        mTittle = ((TextView) rootView.findViewById(R.id.title));
        mType = ((TextView) rootView.findViewById(R.id.type));
        mSize = ((TextView) rootView.findViewById(R.id.size));
        mScore = ((TextView) rootView.findViewById(R.id.score));
        mDownloadCount = ((TextView) rootView.findViewById(R.id.downloadCount));
        mIcon = ((ImageView) rootView.findViewById(R.id.icon));
    }

    @Override
    public void onbind(Object object) {
        ValueBean valueBean = (ValueBean) object;
        mTittle.setText(valueBean.getTitle());
        mSize.setText(TextFormaterUtils.getDataSize(valueBean.getSize()) + "");
        mType.setText(valueBean.getCategory());
        mScore .setText("评分" + valueBean.getRate() + "");
        mDownloadCount.setText("下载量" + valueBean.getDownloadCount() + "");
        Glide.with(mContext).load(valueBean.getIcon()).into(mIcon);
    }
}
